package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                                                                                                import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ProductDeferredInfoMapper;
import com.ruoyi.bizsys.domain.ProductDeferredInfo;
import com.ruoyi.bizsys.service.IProductDeferredInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 产品延期金融包Service业务层处理
 *
 * @author wqg
 * @date 2022-06-09
 */
@Service
public class ProductDeferredInfoServiceImpl extends ServiceImpl<ProductDeferredInfoMapper,ProductDeferredInfo> implements IProductDeferredInfoService {


    @Autowired
    private  ProductDeferredInfoMapper productDeferredInfoMapper;
    /**
     * 查询产品延期金融包
     *
     * @param id 产品延期金融包ID
     * @return 产品延期金融包
     */
    @Override
    public ProductDeferredInfo selectProductDeferredInfoById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询产品延期金融包列表
     *
     * @param productDeferredInfo 产品延期金融包
     * @return 产品延期金融包
     */
    @Override
    public List<ProductDeferredInfo> selectProductDeferredInfoList(ProductDeferredInfo productDeferredInfo) {
        return this.list(new QueryWrapper<>(productDeferredInfo).last("order by id desc"));
    }

    /**
     * 新增产品延期金融包
     *
     * @param productDeferredInfo 产品延期金融包
     * @return 结果
     */
            @Override
    public int insertProductDeferredInfo(ProductDeferredInfo productDeferredInfo) {
                                                                                                                                                                                                                                                                                                                                                                                        productDeferredInfo.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(productDeferredInfo);
    }

    /**
     * 修改产品延期金融包
     *
     * @param productDeferredInfo 产品延期金融包
     * @return 结果
     */
            @Override
    public int updateProductDeferredInfo(ProductDeferredInfo productDeferredInfo) {
                                                                                                                                                                                                                                                                                                                                                                                                                                productDeferredInfo.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(productDeferredInfo);
    }

    /**
     * 批量删除产品延期金融包
     *
     * @param ids 需要删除的产品延期金融包ID
     * @return 结果
     */
            @Override
    public int deleteProductDeferredInfoByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除产品延期金融包信息
     *
     * @param id 产品延期金融包ID
     * @return 结果
     */
    @Override
    public int deleteProductDeferredInfoById(Long id) {
        return baseMapper.deleteById(id);
    }

    /**
     * 获取延期产品金融包列表
     * @return
     */
    @Override
    public List<ProductDeferredInfo> getlist(ProductDeferredInfo productDeferredInfo) {
        return productDeferredInfoMapper.selectLists(productDeferredInfo);
    }

    @Override
    public Integer deleteProductDeferredInfo(Long[] ids) {
        return productDeferredInfoMapper.updateIds(Arrays.asList(ids));

    }

    @Override
    public ProductDeferredInfo selectProductDeferredInfo(String creditRating) {
        return productDeferredInfoMapper.selectProductDeferredInfo(creditRating);
    }

    @Override
    public ProductDeferredInfo selectproductDeferred(String productId, String day) {
        return productDeferredInfoMapper.selectproductDeferred(productId, day);
    }

}
